babl: reduce amount of instrumentation
authorØyvind Kolås <pippin@gimp.org>
Mon, 15 Jan 2018 13:21:59 +0000 (14:21 +0100)
committerØyvind Kolås <pippin@gimp.org>
Mon, 15 Jan 2018 13:26:05 +0000 (14:26 +0100)
The integer counter for number of processings overflows in some scenarios, thus
cannot be relied on for more than being informative.

We might ultimately want to also drop the instrumentation.

12 files changed:
babl/babl-cache.c
babl/babl-conversion.c
babl/babl-conversion.h
babl/babl-fish-path.c
babl/babl-fish-reference.c
babl/babl-fish-simple.c
babl/babl-fish.h
babl/babl-format.c
babl/babl-internal.h
babl/babl-introspect.c
babl/babl-model.c
babl/babl-type.c

index dcc76f4064899df0b6f5182e1bd08ff773d324ed..75780b50681a0c95b5b2d986ca1933893ffe10c6 100644 (file)
@@ -119,9 +119,6 @@ babl_fish_serialize (Babl *fish, char *dest, int n)
   snprintf (d, n, "\tpixels=%li", fish->fish.pixels);
   n -= strlen (d);d += strlen (d);
 
-  snprintf (d, n, " processings=%i", fish->fish.processings);
-  n -= strlen (d);d += strlen (d);
-
   snprintf (d, n, " cost=%d", (int)fish->fish_path.cost);
   n -= strlen (d);d += strlen (d);
 
@@ -145,8 +142,7 @@ static int compare_fish_pixels (const void *a, const void *b)
 {
   const Babl **fa = (void*)a;
   const Babl **fb = (void*)b;
-  return ((*fb)->fish.pixels - (*fa)->fish.pixels) +
-         ((*fb)->fish.processings - (*fa)->fish.processings);
+  return ((*fb)->fish.pixels - (*fa)->fish.pixels);
 }
 
 static const char *cache_header (void)
@@ -240,7 +236,7 @@ void babl_init_db (void)
         case '-': /* finalize */
           if (babl)
           {
-            if (((babl->fish.pixels + babl->fish.processings) % 100) == (tim % 100))
+            if ((babl->fish.pixels) == (tim % 100))
             {
               /* 1% chance of individual cached conversions being dropped -
                * making sure mis-measured conversions do not
@@ -309,10 +305,6 @@ void babl_init_db (void)
               {
                 babl->fish.pixels = strtol (token2 + 7, NULL, 10);
               }
-              else if (!strncmp (token2, "processings=", 12))
-              {
-                babl->fish.processings = strtol (token2 + 12, NULL, 10);
-              }
               token2 = strtok_r (NULL, seps2, &tokp2);
             }
           }
index 78a5f1fa9d712cd329d8df2c617e0ee2559e207c..8add99abe91377557645576398c1ce2dccc15da5 100644 (file)
@@ -219,7 +219,6 @@ _conversion_new (const char    *name,
   babl->conversion.cost        = 69L;
 
   babl->conversion.pixels      = 0;
-  babl->conversion.processings = 0;
 
   babl->conversion.data = user_data;
 
@@ -511,10 +510,6 @@ babl_conversion_error (BablConversion *conversion)
                               ref_destination_rgba_double,
                               test_pixels * 4);
 
-  fish_rgba_to_source->fish.processings--;
-  fish_reference->fish.processings--;
-  fish_destination_to_rgba->fish.processings -= 2;
-
   fish_rgba_to_source->fish.pixels      -= test_pixels;
   fish_reference->fish.pixels           -= test_pixels;
   fish_destination_to_rgba->fish.pixels -= 2 * test_pixels;
index f373e381cb54c89f3a1eefce20fddd094fc1c372..023625a5f0aead90d8b45a7dd5375158ace9ab00 100644 (file)
@@ -54,7 +54,6 @@ _BablConversion {
       BablFuncPlane      plane;
       BablFuncPlanar     planar;
     } function;
-  int                    processings;
   long                   pixels;
 };
 
index d384e1c02abad790b6256a3715f830243f6b2a85..19d7f14cbbe7ee33bab26ef6d1dc22a9a922f1c7 100644 (file)
@@ -536,7 +536,6 @@ babl_fish_path2 (const Babl *source,
   strcpy (babl->instance.name, name);
   babl->fish.source               = source;
   babl->fish.destination          = destination;
-  babl->fish.processings          = 0;
   babl->fish.pixels               = 0;
   babl->fish.error                = BABL_MAX_COST_VALUE;
   babl->fish_path.cost            = BABL_MAX_COST_VALUE;
@@ -736,7 +735,6 @@ _babl_process (const Babl *cbabl,
                long        n)
 {
   Babl *babl = (void*)cbabl;
-  babl->fish.processings++;
   babl->fish.pixels += n;
   babl->fish.dispatch (babl, source, destination, n, *babl->fish.data);
   return n;
@@ -770,7 +768,6 @@ babl_process_rows (const Babl *fish,
   if (n <= 0)
     return 0;
 
-  babl->fish.processings++;
   babl->fish.pixels += n * rows;
   for (row = 0; row < rows; row++)
     {
index 695c3ca771bedbe616b2b231eeb710220982e070..54ca11021c2229ecfc1b0cd69ba28cb1462d1135 100644 (file)
@@ -134,7 +134,6 @@ babl_fish_reference (const Babl *source,
   babl->fish.source      = source;
   babl->fish.destination = destination;
 
-  babl->fish.processings = 0;
   babl->fish.pixels      = 0;
   babl->fish.error       = 0.0;  /* assuming the provided reference conversions for types
                                     and models are as exact as possible
index 1fa338416e2846bfc28b7e190c06e4a043e146de..a6a3730888c75f0e5f778fa38c5e5c5f8ebbebcd 100644 (file)
@@ -51,7 +51,6 @@ babl_fish_simple (BablConversion *conversion)
   babl->fish.source      = conversion->source;
   babl->fish.destination = conversion->destination;
 
-  babl->fish.processings       = 0;
   babl->fish.pixels            = 0;
   babl->fish_simple.conversion = conversion;
   babl->fish.error             = 0.0;/* babl fish simple should only be used by bablfish
index a73a358f1b05b1018722cd123ed131cb59b24370..a26a0322d9252cea69edfa078aa9b5e7b2efc8e0 100644 (file)
@@ -33,19 +33,15 @@ typedef struct
   const Babl     *destination;
   void           (*dispatch) (const Babl *babl, const char *src, char *dst, long n, void *data);
   void          **data;      /* user data - only used for conversion redirect  */
+  long            pixels;      /* number of pixels translates */
   double          error;    /* the amount of noise introduced by the fish */
-
   /* instrumentation */
-  int             processings; /* number of times the fish has been used */
-  long            pixels;      /* number of pixels translates */
-  long            usecs;       /* usecs spent within this fish */
 } BablFish;
 
 /* BablFishSimple is the simplest type of fish, wrapping a single
  * conversion function, (note this might not be the optimal chosen
- * conversion even if it exists)
- *
- * TODO: exterminate
+ * conversion even if it exists), these fishes are used internally for
+ * instance in reference fishes.
  */
 typedef struct
 {
index 45c62b26e817e2d2691522446825d1ffa5f1ca6d..1db5f023797fcf74571bb3b65e76b11ef762a649 100644 (file)
@@ -643,8 +643,6 @@ babl_format_loss (const Babl *babl)
 
   loss = babl_rel_avg_error (clipped, test, test_pixels * 4);
 
-  fish_to->fish.processings   -= 2;
-  fish_from->fish.processings -= 2;
   fish_to->fish.pixels        -= test_pixels * 2;
   fish_from->fish.pixels      -= test_pixels * 2;
 
index 9d29b47dc8370b04fa9593e810391a8a07c5eb3d..ff837958d7106e183d9a62372ddcb5b4b9ba1a15 100644 (file)
@@ -491,7 +491,6 @@ babl_conversion_process (const Babl *babl,
                          long        n)
 {
   BablConversion *conversion = (BablConversion *) babl;
-  conversion->processings++;
   conversion->pixels += n;
   conversion->dispatch (babl, source, destination, n, conversion->data);
 }
index 03cfef17f230b59a0eba26edee452d5847d2f681..5d0cb9d27011f708b10c4e21c5ee9113ea102097 100644 (file)
@@ -166,8 +166,7 @@ format_introspect (Babl *babl)
 static void
 conversion_introspect (Babl *babl)
 {
-  babl_log ("\t\tprocessings:%i pixels:%li",
-            babl->conversion.processings, babl->conversion.pixels);
+  babl_log ("\t\tpixels:%li", babl->conversion.pixels);
   if (BABL (babl->conversion.source)->class_type == BABL_FORMAT)
     {
       babl_log ("\t\terror: %f", babl_conversion_error (&babl->conversion));
@@ -177,8 +176,7 @@ conversion_introspect (Babl *babl)
 static void
 fish_introspect (Babl *babl)
 {
-  babl_log ("\t\tprocessings:%i pixels:%li",
-            babl->fish.processings, babl->fish.pixels);
+  babl_log ("\t\tpixels:%li", babl->fish.pixels);
 }
 
 static void
index d553aca73ce723a03290057fbd42240894ee6499..2156059065345c49ca0f78286f40e2c068fd7261 100644 (file)
@@ -315,8 +315,6 @@ babl_model_is_symmetric (const Babl *cbabl)
   babl_process (fish_to, clipped, destination, test_pixels);
   babl_process (fish_from, destination, transformed, test_pixels);
 
-  fish_to->fish.processings   -= 2;
-  fish_from->fish.processings -= 2;
   fish_to->fish.pixels        -= test_pixels * 2;
   fish_from->fish.pixels      -= test_pixels * 2;
 
index f99c9d1817a10340069b875407820835acef0960..86b1a3fdeede30c9b1f8ceea3e51e535f3bc6e59 100644 (file)
@@ -209,8 +209,6 @@ babl_type_is_symmetric (const Babl *babl)
   babl_process (fish_to, clipped, destination, samples);
   babl_process (fish_from, destination, transformed, samples);
 
-  fish_from->fish.processings -= 2;
-  fish_to->fish.processings   -= 2;
   fish_from->fish.pixels      -= samples * 2;
   fish_to->fish.pixels        -= samples * 2;